import requests
from bs4 import BeautifulSoup


def xinxi():
    list1 = []
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'
    }

    url = 'https://www.ccdi.gov.cn/scdcn/zggb/djcf/'
    ccid = requests.get(url,headers=headers)

    ccid.encoding = "UTF-8"

    dada = BeautifulSoup(ccid.text,'html.parser')

    li = dada.select("body > section > ul > li")


    for i in li:
        zidian = {}
        text = str(i.a.string).strip()
        try:
            addr = text.index('省')
            addr1 = text[0:addr + 1]
            zidian['province'] = addr1
        except Exception as e:
            try:
                addrs = text.index('市')
                addr2 = text[0:addrs + 1]
                zidian['province'] = addr2
            except:
                zidian['province'] = ''

        # 名字
        try:
            name = text.index('严重')
            name1 = text[name-3:name]
            if name1 == '席李佳' or name1 == '席黄毅':
                name1 = text[name - 2:name]
            zidian['name'] = name1
        except:
            zidian['name'] = ''

        # 职务
        try:
            post = text.index('严重')
            posts = text.index('原')
            name1 = text[post - 3:post]
            zhi = 0
            if name1 == '席李佳' or name1 == '席黄毅':
                zhi = post - 2
            else:
                zhi = post - 3

            post1 = text[posts+1:zhi]
            zidian['post'] = post1
        except:
            zidian['post'] = ''

        # 处分
        try:
            punishment = text.index('被')

            punishment1 = text[punishment+1:]
            zidian['punishment'] = punishment1
        except:
            zidian['punishment'] = ''

        riqi = str(i.span.string).strip()
        zidian['date'] = riqi
        list1.append(zidian)
    return list1











